package com.alex.algorithm.easy;

public class MoveZero {

    public static void main(String[] args) {
        int[] array = new int[]{0,1,2,4,0,5,0,6};
        moveZero(array);
        for (int i = 0; i < array.length; ++i) {
            System.out.println(array[i]);
        }
    }

    public static void moveZero(int[] nums){
        int index  = 0;
        for (int i = 0; i < nums.length; ++i) {
            if (nums[i] != 0) {
                nums[index++] = nums[i];
            }
        }
        for (int j = index; j < nums.length; ++j) {
            nums[j] = 0;
        }

    }
}
